//
//  SbVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/11/30.
//

import Foundation

extension SbVC {
    
    func initUI() {
        
        back_view2 = UIView.init()
        view.addSubview(back_view2)
        back_view2.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        back_view1 = UIView.init()
        back_view1.backgroundColor = UIColor.white
        view.addSubview(back_view1)
        back_view1.snp.makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsets.init(top: UIDevice.lgf_NavBarH(), left: 0, bottom: 0, right: 0))
        }
        
        self.navTitle = "设备"
        self.lgf_NavigationBar.lgf_line?.isHidden = true
        self.lgf_NavigationBar.lgf_Title?.textColor = UIColor.white
        
        let image_view1 = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        back_view2.addSubview(image_view1)
        image_view1.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(150)
        }
        
        let image_view2 = UIImageView.init(image: #imageLiteral(resourceName: "shebei@1.5x"))
        image_view1.addSubview(image_view2)
        image_view2.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.width.height.equalTo(18)
            make.centerY.equalToSuperview().multipliedBy(1.6)
        }
        
        let label2 = UILabel.init()
        label2.text = "设备编号："
        label2.textColor = UIColor.white
        label2.font = UIFont.boldSystemFont(ofSize: 15)
        image_view1.addSubview(label2)
        label2.snp.makeConstraints { (make) in
            make.left.equalTo(image_view2.snp.right).offset(5)
            make.centerY.equalTo(image_view2)
            make.width.equalTo(80)
        }
        
        sbbh = UILabel.init()
        sbbh.lgf_AddShowAllText()
        sbbh.text = EWEBluetooth.lgf.selectPeripheral?.identifier.uuidString ?? "未知"
        sbbh.textColor = UIColor.white
        sbbh.numberOfLines = 1
        sbbh.font = UIFont.boldSystemFont(ofSize: 15)
        image_view1.addSubview(sbbh)
        sbbh.snp.makeConstraints { (make) in
            make.left.equalTo(label2.snp.right)
            make.centerY.equalTo(image_view2)
            make.width.equalTo(150)
        }
        
        onLine = UILabel.init()
        onLine.text = "离线"
        onLine.textColor = UIColor.white
        onLine.font = UIFont.boldSystemFont(ofSize: 15)
        image_view1.addSubview(onLine)
        onLine.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-20)
            make.centerY.equalTo(image_view2)
        }
        
        onOff = UIView.init()
        onOff.backgroundColor = UIColor.red
        onOff.layer.cornerRadius = 5
        image_view1.addSubview(onOff)
        onOff.snp.makeConstraints { (make) in
            make.width.height.equalTo(10)
            make.right.equalTo(onLine.snp.left).offset(-5)
            make.centerY.equalTo(image_view2)
        }
        
        let scrollView = UIScrollView.lgf_Table("FFFFFF")
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
        back_view2.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.top.equalTo(image_view1.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        
        let tzydms = UIImageView.init(image: #imageLiteral(resourceName: "shaixuan@1.5x"))
        tzydms.isUserInteractionEnabled = true
        tzydms.lgf_AddTap(target: self, action: #selector(goTzydms))
        scrollView.addSubview(tzydms)
        tzydms.snp.makeConstraints { (make) in
            make.top.left.equalToSuperview().offset(20)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-30)
            make.height.equalTo(view.lgf_Width / 2 - 30)
        }
        
        let tzydms_label1 = UILabel.init()
        tzydms_label1.text = "听诊引导模式"
        tzydms_label1.font = UIFont.systemFont(ofSize: 18)
        tzydms_label1.textColor = UIColor.white
        tzydms.addSubview(tzydms_label1)
        tzydms_label1.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview().multipliedBy(0.5)
            make.left.equalToSuperview().offset(20)
        }
        
        let tzydms_label2 = UILabel.init()
        tzydms_label2.text = "Screening"
        tzydms_label2.font = UIFont.systemFont(ofSize: 14)
        tzydms_label2.textColor = UIColor.white
        tzydms.addSubview(tzydms_label2)
        tzydms_label2.snp.makeConstraints { (make) in
            make.top.equalTo(tzydms_label1.snp.bottom).offset(5)
            make.left.equalToSuperview().offset(20)
        }
        
        let xyybcj = UIImageView.init(image: #imageLiteral(resourceName: "caiji@1.5x"))
        xyybcj.isUserInteractionEnabled = true
        xyybcj.lgf_AddTap(target: self, action: #selector(goXyybcj))
        scrollView.addSubview(xyybcj)
        xyybcj.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(20)
            make.left.equalTo(tzydms.snp.right).offset(20)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-30)
            make.height.equalTo(view.lgf_Width / 2 - 30)
        }
        
        let xyybcj_label1 = UILabel.init()
        xyybcj_label1.text = "心音样本采集"
        xyybcj_label1.font = UIFont.systemFont(ofSize: 18)
        xyybcj_label1.textColor = UIColor.white
        xyybcj.addSubview(xyybcj_label1)
        xyybcj_label1.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview().multipliedBy(0.5)
            make.left.equalToSuperview().offset(20)
        }
        
        let xyybcj_label2 = UILabel.init()
        xyybcj_label2.text = "Collection"
        xyybcj_label2.font = UIFont.systemFont(ofSize: 14)
        xyybcj_label2.textColor = UIColor.white
        xyybcj.addSubview(xyybcj_label2)
        xyybcj_label2.snp.makeConstraints { (make) in
            make.top.equalTo(tzydms_label1.snp.bottom).offset(5)
            make.left.equalToSuperview().offset(20)
        }
        
        let sbwjhq = UIImageView.init(image: #imageLiteral(resourceName: "微信图片_20201225164910"))
        sbwjhq.isUserInteractionEnabled = true
        sbwjhq.lgf_AddTap(target: self, action: #selector(goSbwjhq))
        scrollView.addSubview(sbwjhq)
        sbwjhq.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(20)
            make.top.equalTo(tzydms.snp.bottom).offset(20)
            make.width.equalToSuperview().multipliedBy(0.5).offset(-30)
            make.height.equalTo(view.lgf_Width / 2 - 30)
        }
        
        let sbwjhq_label1 = UILabel.init()
        sbwjhq_label1.text = "设备文件获取"
        sbwjhq_label1.font = UIFont.systemFont(ofSize: 18)
        sbwjhq_label1.textColor = UIColor.white
        sbwjhq.addSubview(sbwjhq_label1)
        sbwjhq_label1.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview().multipliedBy(0.5)
            make.left.equalToSuperview().offset(20)
        }
        
        let sbwjhq_label2 = UILabel.init()
        sbwjhq_label2.text = "Download"
        sbwjhq_label2.font = UIFont.systemFont(ofSize: 14)
        sbwjhq_label2.textColor = UIColor.white
        sbwjhq.addSubview(sbwjhq_label2)
        sbwjhq_label2.snp.makeConstraints { (make) in
            make.top.equalTo(sbwjhq_label1.snp.bottom).offset(5)
            make.left.equalToSuperview().offset(20)
        }
        
        scrollView.lgf_AutoContentSize(0)

        let view1 = UIView.init()
        view1.layer.cornerRadius = UIDevice.lgf_ScreenW / 4
        view1.layer.borderWidth = 10
        view1.layer.borderColor = UIColor.init(lgf_HexString: "C2E6FA")?.cgColor
        back_view1.addSubview(view1)
        view1.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().multipliedBy(0.7)
            make.width.height.equalTo(UIDevice.lgf_ScreenW / 2)
        }

        let image_view3 = UIImageView.init(image: #imageLiteral(resourceName: "BlueTooth"))
        back_view1.addSubview(image_view3)
        image_view3.snp.makeConstraints { (make) in
            make.center.equalTo(view1)
            make.width.height.equalTo(UIDevice.lgf_ScreenW / 3)
        }

        let label7 = UILabel.init()
        label7.textAlignment = .center
        label7.text = "请打开设备并打开手机蓝牙点击添加设备"
        label7.numberOfLines = 3
        back_view1.addSubview(label7)
        label7.snp.makeConstraints { (make) in
            make.top.equalTo(view1.snp.bottom).offset(20)
            make.centerX.equalTo(view1)
            make.width.equalTo(UIDevice.lgf_ScreenW / 1.7)
        }

        let tjsb = UILabel.init()
        tjsb.text = "添加设备"
        tjsb.layer.cornerRadius = 22
        tjsb.clipsToBounds = true
        tjsb.backgroundColor = UIColor.init(lgf_HexString: "0F88F2")!
        tjsb.font = UIFont.boldSystemFont(ofSize: 15)
        tjsb.isUserInteractionEnabled = true
        tjsb.textColor = UIColor.white
        tjsb.textAlignment = .center
        tjsb.lgf_AddTap(target: self, action: #selector(SbVC.s_tjsb(_:)))
        back_view1.addSubview(tjsb)
        tjsb.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview().offset(-80)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-80.lgf_W())
            make.height.equalTo(44)
        }
    }
    
}
